package com.Nuyoah.demo01.controller;

import com.Nuyoah.demo01.common.JsonResult;
import com.Nuyoah.demo01.entity.Rank;
import com.Nuyoah.demo01.service.RankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/ranks")
public class RankController {

    @Autowired
    private RankService rankService;
    @PostMapping("/getRank")
    public JsonResult<List<Rank>> getRank() {
        List<Rank> rank = rankService.getRank();
        if (rank != null && !rank.isEmpty()) {
            return new JsonResult<>("200",rank,"查询成功");
        } else {
            return new JsonResult<>("1", "没有数据");
        }
    }
}
